/*****************************************************************************
 * plum_hal_flash.h
 *
 * Copyright (C) 2020 Jeasonvor <1101627719@qq.com>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 ****************************************************************************/

#ifndef __PLUM_HAL_FLASH_H__
#define __PLUM_HAL_FLASH_H__
/*****************************************************************************
 * Included Files
 ****************************************************************************/

/*****************************************************************************
 * Pre-processor Definitions
 ****************************************************************************/

/*****************************************************************************
 * Public Types
 ****************************************************************************/

/*****************************************************************************
 * Public Data
 ****************************************************************************/

/****************************************************************************/
#ifdef __cplusplus
extern "C" {
#endif
/*****************************************************************************
 * Public Function Prototypes
 ****************************************************************************/

/**
 * @brief:  flash读数据
 *
 * @param[in]:  id      -   flash ID，通常为扇区号
 * @param[in]:  offset  -   地址偏移(相对于扇区起始地址的偏移)
 * @param[out]: rData   -   数据指针
 * @param[in]:  size    -   数据长度
 *
 * @return: 成功    -   返回读取到的数据长度
 *          失败    -   返回错误码
 **/
plum_s32 plum_hal_flash_read(plum_u32 id, plum_u32 offset, plum_u8 *rData,
                             plum_u32 size);

/**
 * @brief:  flash写数据
 *
 * @param[in]:  id      -   flash ID
 * @param[in]:  offset  -   地址偏移(相对于扇区起始位置的偏移)
 * @param[in]:  wData   -   数据指针
 * @param[in]:  size    -   数据字节长度
 *
 * @return: 成功    -   返回写入的数据长度
 *          失败    -   返回错误码
 **/
plum_s32 plum_hal_flash_write(plum_u32 id, plum_u32 offset, plum_u8 *wData,
                              plum_u32 size);

/**
 * @brief:  flash擦除数据
 *
 * @param[in]:  id      -   flash ID
 * @param[in]:  offset  -   地址偏移(相对扇区起始位置的偏移)
 * @param[in]:  size    -   数据字节长度
 *
 * @return: 成功    -   返回擦除的数据长度
 *          失败    -   返回错误码
 **/
plum_s32 plum_hal_flash_erase(plum_u32 id, plum_u32 offset, plum_u32 size);

/****************************************************************************/
#ifdef __cplusplus
}
#endif
/****************************************************************************/
#endif /* __PLUM_HAL_FLASH_H__ */
/****************************************************************************/

/****************************************************************************/
/*                                                                          */
/*  End of file.                                                            */
/*                                                                          */
/****************************************************************************/
